<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/layouts/include/taglib.jsp" %>

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<meta name="decorator" content="default" />
	<script type="text/javascript">
        var GOBAL_CUST_ROLENO = '<shiro:principal property="roleNo"/>'; //当前用户角色
    </script>
</head>
<body>
<script>
var datatable;
var prjName;
//查询
function queryPrj() {
	
	var oSettings = datatable.fnSettings();
	oSettings._iDisplayStart = 0;
	datatable.fnClearTable(0); //清空数据
	datatable.fnDraw(); //重新加载数据 
}




//保存成功，修改按钮状态
function saveSuc(){
		
}


//完成时间提示
function checkDate(statusName,prjDate){
	var days = DateUtil.dateDiff('d', prjDate, new Date().getTime());//结果为正数（小，大）后面减前面
	if(days>-5&&days<=-3){
		//蓝色预警
		return '<font style="color:blue">'+statusName+'(项目结束时间临近，请督促人员提交项目任务！)'+'</font>';
	}else if(days>-3&&days<=0){
		//黄色警告
		return '<font style="color:yellow">'+statusName+'(项目马上到期,请尽快完成项目)'+'</font>';
	}else if(days>0&&days<=3){
		//红色警告
		return '<font style="color:red">'+statusName+'(项目已超时'+days+'天)'+'</font>';
	}else if(days>3){
		//灰色停止
		return '<font style="color:gray">'+statusName+'(项目已超时'+days+'天,项目已失效)'+'</font>';
	}else if(days<=-5){
		//正常绿色
		return '<font style="color:green">'+statusName+'</font>';
	}
	
}
//修改 
function editPrj(id){
	window.location.href="projectEdit.jsp?id="+id;
}

//查看 阶段信息
function viewPrj(id,prjType){
	window.location.href="step.jsp?prjId="+id;
}

//查看项目信息
function selectPrj(id) {
	window.location.href="projectEdit.jsp?id="+id+"&status='status'";
}

//模糊查询数据
function queryObscurePrj(){
	
	queryPrj();
	
}

function baseQuery(){
	var prjTableColums = [//定义列
	                      {
	          				"mData":"uuid",
	          				"sClass": "center",
	          				"bSortable": false,
	          				"mRender" : function(data, type, row) {
	          					
	          						return '<div class="action-buttons"><span class="vbar"></span><a href="javascript:selectPrj(\''+data+'\')" title="查看项目信息"><i class="icon-eye-open bigger-130"></i></a> <a  href="javascript:viewPrj(\''+data+'\')" title="打开阶段信息"><i class="icon-list-alt bigger-130"></i></a></div>';
	          					
	          				}
	                      },
	                      {
	                    	  "mData":"prjName",
	                    	  "sClass": "center",
		          			  "bSortable": false
		          		  },
	                      {
		          			  "mData": "prjType",
		          			  "sClass": "center",
			          		  "bSortable": false
			          	  },
	                      {
	                    	  "mData":"startDate",
	                    	  "mData": function(data, type, row) {
	          						return DateUtil.dateFormat(data.startDate);
	          				  },
	          				  "sClass": "center",
	          				  "bSortable": false
	                      },
	                      {
	                    	  "mData":"endDate",
	                    	  "mData": function(data, type, row) {
	          						return DateUtil.dateFormat(data.endDate);
	          				  },
	          				  "sClass": "center",
	          				  "bSortable": false
	                      },
	                      {
	                    	  "mData": "projectSize",
	                    	  "sClass": "center",
		          			  "bSortable": false
		          		  },
	                      {
		          			  "mData":"custNo",
		          			  "sClass": "center",
			          		  "bSortable": false
			          	  },
	                      {
			          		  "mData": "statusName",
	                    	  "sClass": "center",
		          			  "bSortable": false,
		                      "mData": function(data, type, row) {
									if(data.status =='30090002'){
			          					return checkDate(data.statusName,data.endDate);
		                    		}else{
		                    			return data.statusName;
		                    		}
								}
	                      },
	                      {
	                    	  "mData": "takeUnit",
	                    	  "sClass": "center",
	                    	  "bSortable": false
	                      },
	                      {
	                    	  "mData":"trainsRoleNo",
	                    	  "sClass": "center",
	                    	  "bSortable": false
	                      }
	              ];
	          	
	              //初始化dataTable
	          	datatable = $('#prjTable').dataTable( {
	              	'sAjaxSource': '${ctx}/pm/project/mainPersonQueryForPrj.do',	//请求数据源 
	              	"fnServerData": function(sSource, aoData, fnCallback,oSettings){
	            		$.extend(aoData,$('#queryForm').serializeArray());
	            		$.ajax({
	        	    		dataType: 'json',
	        	    		url : sSource,
	        	    		data: aoData,
	        	    		success: fnCallback
	            		});		
	              	},
	          		'bServerSide':true,							//是否启动服务器端数据导入
	          		"bLengthChange" : false,
	          		"bInfo" : true,
	          		"bPaginate" : true,
                  	'bFilter': false,                       	//是否使用内置的过滤功能。
                  	'aoColumns': prjTableColums,
                 	"sDom": '<"toolbar">frtip', 
                   	"oLanguage": oLanguage
	          	});             
}

$(document).ready(function() {
	//$('#prjQueryForm').bootstrapValidator();
	//$('#roleSaveForm').data('bootstrapValidator').validate();
	baseQuery();
	initAuth();
	
});
</script>
<div class="row row-default border-ra2">
	<div class="col-sm-12">
		<div class="row row-tt">
			<div class="col-sm-2">
				<h3 class="header header-default">
					项目列表
				</h3>
			</div>
			<br/>
			<div class="col-sm-12">		
				<form class="form-horizontal" id="queryForm">
					<div class="form-group">
						<div class="col-md-4">
							<label for="prjName" class="control-label input-sm col-md-3">项目名称</label>
							<div class="col-md-9">
									<input type="text" class="form-control input-sm" id="prjName" name="prjName" placeholder="项目名称">
							</div>
						</div>
						<div class="col-md-4">
							<label for="prjType" class="col-md-3 control-label input-sm">项目类型</label>
							<div class="col-md-9">
								<tags:select name="prjType" id="prjType" type="pmProjectType" hasBlank="true"></tags:select>
							</div>
						</div>
						<div class="col-md-4">
							<label for="pmProjectStatus" class="col-md-3 control-label input-sm">项目状态</label>
							<div class="col-md-9">
								 <tags:select name="pmProjectStatus" id="pmProjectStatus" type="pmProjectStatus" hasBlank="true"></tags:select>
							</div>
						</div>
					</div>				
				<span class="input-group-btn" style="text-align:center">
							<button type="button" class="btn btn-sm btn-info" onclick="queryObscurePrj();"><i class="icon-search"></i>查询</button>
							<button class="btn btn-sm btn-default" type="reset"><i class="icon-undo"></i>重置</button>
				</span>
				</form>
<!-- 				<form class="form-horizontal" role="form" name="prjQuery" id="prjQueryForm" action="" method="get">
					<div class="input-group">
						<input type="text" class="form-control" id="prj_name" name="prj_name" placeholder="项目名称">
						<span class="input-group-btn">
							<button type="button" class="btn btn-sm btn-info" onclick="queryObscurePrj();"><i class="icon-search"></i>查询</button>
							<button class="btn btn-sm btn-default" type="reset"><i class="icon-undo"></i>重置</button>
						</span>
					</div>
				</form> -->
			</div>

		</div>
			
		<div class="row row-content">
			<div class="col-xs-12">
				<div class="table-responsive">
					<table id="prjTable" class="table table-striped table-bordered table-hover">
						<thead>
							<tr>
								<th width="10%"></th>
								<th width="10%">项目名称</th>
								<th width="10%">项目类型</th>
								<th width="10%">开始时间</th>
								<th width="10%">结束时间</th>
								<th width="10%">项目规模</th>
								<th width="10%">客户名称</th>
								<th width="10%">项目状态</th>
								<th width="10%">所属工作室</th>
								<th width="10%">项目负责人</th>
								
							</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
				</div>
			</div>
		</div>
							
	</div>
</div>
</body>
